<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\admin\models\UserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '用户管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">

    <?php Pjax::begin(); ?>
    <div class="panel">
		<div class="panel-heading panel-heading-auto">
            <?php echo $this->render('_search', ['model' => $searchModel]); ?>
		</div>
        <div class="panel-body">
        
    <p>
        <?= Html::a('添加', ['create'], ['class' => 'btn btn-success', 'title' => '添加新用户']) ?>
        <?= Html::a('删除', ['delete'], ['class' => 'btn btn-danger', 'title' => '删除勾选的用户']) ?>
        <?= Html::a('导入', ['import'], ['class' => 'btn btn-cyan', 'title' => '从Excel文件导入用户']) ?>
        <?= Html::a('导出', ['export'], ['class' => 'btn btn-cyan', 'title' => '把查到的用户导出到Excel文件']) ?>
    </p>

    <?= GridView::widget([
        'layout' => "{items}\n{pager}",
        'tableOptions' => ['class' => 'table table-hover table-bordered'],
        'dataProvider' => $dataProvider,
        //'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\CheckboxColumn'],
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'username',
            //'auth_key',
            //'password_hash',
            //'password_reset_token',
            'email:email',
            [
                'attribute' => 'status',
                'value' => function($model){
                    static $status = [    
                        \backend\modules\admin\models\User::STATUS_ACTIVE => '启用',
                        \backend\modules\admin\models\User::STATUS_INACTIVE => '禁用',
                        \backend\modules\admin\models\User::STATUS_DELETED => '已删除',
                    ];
                    return $status[$model->status]; 
                }
            ],
            'created_at:datetime',
            'updated_at:datetime',
            'last_login_time:datetime',
            'last_login_ip',
            //'verification_token',
            //'person_id',

            ['class' => 'yii\grid\ActionColumn', 'header'=>'操作'],
        ],
    ]); ?>

		</div>
	</div>
    <?php Pjax::end(); ?>

</div>
